package cn.group.hotel2.controller;

import cn.group.hotel2.security.LoginPrincipal;
import cn.group.hotel2.web.JsonResult;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

/**
 * @author wcl
 * @version 0.0.1
 * @date 2022/12/1
 */
@Slf4j
@RestController
@RequestMapping("/login")
@Api(tags = "07r 登录管理模块")
public class LoginPrincipalController {

    public LoginPrincipalController() {
        log.debug("创建控制器对象：LoginPrincipalController");
    }

    @ApiOperation("获取当前登录的当事人信息")
    @ApiOperationSupport(order = 100)
    @GetMapping("getLoginPrincipal")
    public JsonResult<LoginPrincipal> getLoginPrincipal(
            @ApiIgnore @AuthenticationPrincipal LoginPrincipal loginPrincipal) {
        log.debug("开始处理【获取当前登录的当事人信息】的请求，参数:{}", loginPrincipal);
        return JsonResult.ok(loginPrincipal);
    }
}
